home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / com_and3.zip / DIALER.CMD < prev    next >
OS/2 REXX Batch file  |  1990-06-22  |  19KB  |  821 lines

  1. ; ----- COM-AND Multi-dialer script
  2. ;
  3. ;    This script opens a window and asks for up to 10 dialing directory
  4. ;    numbers (with or without long distance prefix).  As numbers are
  5. ;    selected, the dialing directory values are displayed (and the dialing
  6. ;    directory may be cycled through, searching).
  7. ;
  8. ;    When dialing is initiated, the current selections are saved to a file
  9. ;    on the current drive/subdirectory named DIALER.DAT.  If a connection
  10. ;    is made, the DIALER.DAT is updated to eliminate the connection just
  11. ;    made from the list.
  12. ;
  13. ;    If a script is associated with the dialing directory entry to which
  14. ;    connection is made, it is EXECUTED just as if from Alt-D.
  15. ;
  16. ;    R.McG, commenced 10/88
  17. ;           updated      3/89 (CLOG start and hit, and add alarm)
  18. ; ----- Usages -----------------
  19. ;    S19 -----> Parameter string read/written to the .DAT file
  20. ;    N8 ------> Saved cursor row #
  21. ;    N9 ------> Saved cursor col #
  22. ;    N10-N19 -> Working storage for the screen display (LD# and DD#)
  23. ; ------------------------------
  24. ;    Initialization
  25. ;
  26. ;* TRACE ON
  27.    CLEAR
  28.    CURSOR N8,N9             ; Save cursor on entry
  29.    ON ESCAPE GOSUB Exit         ; SAVE is performed in Window
  30.    LEGEND " Multi-dialer pop-up"
  31.    SET TTHRU OFF            ; Disallow typeahead
  32.    CLOG "* Dialer multi-dialer invoked"
  33. ;
  34. ;    Paint an initial window, using saved values
  35. ;
  36.    GOSUB Window             ; Open the window
  37.    GOSUB Get_Last            ; Get last Parm string
  38.    GOSUB Parse_Parm            ; Parse_Parms
  39.    GOSUB All_Fields            ; Display all fields
  40.  
  41.    LOCATE 7,8                ; Set cursor to 1st entry
  42. ;
  43. ;    Main-loop - look for keyentry
  44. ;
  45. Main_Loop:
  46.    SET TTHRU OFF            ; Disallow typeahead
  47.    KEYGET S0                ; Get a keystroke
  48. ;
  49. ;    Act upon the keystroke
  50. ;
  51. Have_Key:
  52.    SWITCH S0
  53.       CASE "4900"                       ; Pgup
  54.      GOTO PgUp
  55.       ENDCASE
  56.       CASE "5100"                       ; PgDn
  57.      GOTO PgDn
  58.       ENDCASE
  59.       CASE "4700"                       ; Home
  60.      GOTO Home
  61.       ENDCASE
  62.       CASE "4F00"                       ; End
  63.      GOTO End
  64.       ENDCASE
  65.       CASE "0D"                         ; C/r
  66.      GOTO Perform
  67.       ENDCASE
  68.       CASE "4800"                       ; Cursor up
  69.      GOTO UpLine
  70.       ENDCASE
  71.       CASE "5000"                       ; Cursor down
  72.      GOTO DnLine
  73.       ENDCASE
  74.       CASE "4B00"                       ; Cursor Left
  75.      GOTO Left
  76.       ENDCASE
  77.       CASE "4D00"                       ; Cursor right
  78.      GOTO Right
  79.       ENDCASE
  80.       CASE "09"                         ; Tab
  81.      GOTO Right
  82.       ENDCASE
  83.       CASE "0F00"                       ; Shift-tab
  84.      GOTO Left
  85.       ENDCASE
  86.    ENDSWITCH
  87. ;
  88. ;     Any other keystrokes must be ASCII keys
  89. ;
  90.    IF NOT NULL S0(1:3)
  91.       SOUND 100,100
  92.       GOTO Main_Loop
  93.       ENDIF
  94. ;
  95. ;     Decide where we are by the current cursor, and begin field entry
  96. ;
  97.    CURSOR N0,N1
  98.    IF GE N1 11
  99.       GOSUB Enter_DD            ; Enter dialing directory #
  100.       GOTO Have_Key            ; Return with a new keystroke
  101.    ELSE
  102.       GOSUB Enter_LD            ; Enter Long distance #
  103.       GOTO Right            ; Move to next field
  104.       ENDIF
  105. ;
  106. ; ----- Page up (cycle backwards through possible values)
  107. ;
  108. PgUp:
  109.    CURSOR N1,N2
  110.    IF GE N2 11
  111.       N0 = N10[N1-7]
  112.       N3 = N0/1000            ; Cycle DD#
  113.       N0 = N0-(N0/1000)*1000
  114.       N0 = N0-1
  115.       IF LT N0 0
  116.      N0 = 100
  117.      ENDIF
  118.       N0 = N0+N3*1000
  119.    ELSE
  120.       N0 = N10[N1-7]
  121.       N3 = N0-(N0/1000)*1000        ; Cycle LD#
  122.       N0 = N0/1000
  123.       N0 = N0-1
  124.       IF LT N0 0
  125.      N0 = 4
  126.      ENDIF
  127.       N0 = N3+N0*1000
  128.       ENDIF
  129. ;
  130. ;    Restore the value (N0, index N1) and display
  131. ;
  132.    N10[N1-7] = N0
  133.    GOSUB One_Field
  134.    GOTO Main_Loop
  135. ;
  136. ; ----- Page down (cycle forwards through possible values)
  137. ;
  138. PgDn:
  139.    CURSOR N1,N2
  140.    IF GE N2 11
  141.       N0 = N10[N1-7]
  142.       N3 = N0/1000            ; Cycle DD#
  143.       N0 = N0-(N0/1000)*1000
  144.       N0 = N0+1
  145.       IF GT N0 100
  146.      N0 = 0
  147.      ENDIF
  148.       N0 = N0+N3*1000
  149.       N10[N1-7] = N0
  150.       GOSUB One_Field
  151.    ELSE
  152.       N0 = N10[N1-7]
  153.       N3 = N0-(N0/1000)*1000        ; Cycle LD#
  154.       N0 = N0/1000
  155.       N0 = N0+1
  156.       IF GT N0 4
  157.      N0 = 0
  158.      ENDIF
  159.       N0 = N3+N0*1000
  160.       ENDIF
  161. ;
  162. ;    Restore the value (N0, index N1) and display
  163. ;
  164.    N10[N1-7] = N0
  165.    GOSUB One_Field
  166.    GOTO Main_Loop
  167. ;
  168. ; ----- Up a line
  169. ;
  170. UpLine:
  171.    CURSOR N0,N1
  172.    N0 = N0-1
  173.    IF LT N0 7
  174.       N0 = 16
  175.       ENDIF
  176.    IF GE N1 11
  177.       N1 = 11                ; Set new start-of-field
  178.    ELSE
  179.       N1 = 8                ; Set new start-of-field
  180.       ENDIF
  181.    LOCATE N0,N1
  182.    GOTO Main_Loop
  183. ;
  184. ; ----- Down a line
  185. ;
  186. DnLine:
  187.    CURSOR N0,N1
  188.    N0 = N0+1
  189.    IF GT N0 16
  190.       N0 = 7
  191.       ENDIF
  192.    IF GE N1 11
  193.       N1 = 11                ; Set new start-of-field
  194.    ELSE
  195.       N1 = 8                ; Set new start-of-field
  196.       ENDIF
  197.    LOCATE N0,N1
  198.    GOTO Main_Loop
  199. ;
  200. ; ----- Home (move to first line)
  201. ;
  202. Home:
  203.    LOCATE 7,8
  204.    GOTO Main_Loop
  205. ;
  206. ; ----- End (Move to last line)
  207. ;
  208. End:
  209.    LOCATE 11,8
  210.    GOTO Main_Loop
  211. ;
  212. ; ----- Left (Next field)
  213. ;
  214. Left:
  215.    CURSOR N0,N1
  216.    IF GE N1 11
  217.       N1 = 8                ; Move to previous field
  218.    ELSE
  219.       N0 = N0-1             ; Move to previous line
  220.       N1 = 11
  221.       ENDIF
  222.    IF LT N0 7                ; Last field
  223.       N0 = 16                ; Wrap
  224.       ENDIF
  225.    LOCATE N0,N1             ; And reposition cursor
  226.    GOTO Main_Loop
  227. ;
  228. ; ----- Right (Previous field)
  229. ;
  230. Right:
  231.    CURSOR N0,N1
  232.    IF GE N1 11
  233.       N0 = N0+1             ; Move to next row
  234.       N1 = 8
  235.    ELSE
  236.       N1 = 11                ; Move to next field
  237.       ENDIF
  238.    IF GT N0 16                ; Last field
  239.       N0 = 7                ; Wrap
  240.       ENDIF
  241.    LOCATE N0,N1             ; And reposition cursor
  242.    GOTO Main_Loop
  243. ;
  244. ; ----- Subroutine Exit - terminate the process
  245. ;
  246. Exit:
  247.    RESTORE                ; Saved screen
  248.    LOCATE N8,N9             ; Restore cursor
  249.    EXIT
  250. ;
  251. ; ----- Subroutine: Enter a dialing directory #
  252. ;    .. on entry S0 -> The first keystroke
  253. ;    .. N1 within this subroutine is always current row#
  254. ;    .. S9 within this subroutine the field being constructed
  255. ;    .. N6 within this subroutine is an index to field being constructed
  256. ;
  257. Enter_DD:
  258.    CURSOR N1,N2             ; Get current row
  259.    N0 = N10[N1-7]
  260.    N0 = (N0/1000)*1000            ; Fake a 0 DD# with old LD#
  261.    GOSUB One_Field            ; Clear previous values on screen
  262.    N6 = 0                ; Index to field being built
  263.    S9 = ""                              ; Clear field
  264. ;
  265. ;    Look for an initial space or backspace (this 'blank's the field)
  266. ;
  267.    IF STRCMP S0 " "                     ; If enter with space
  268.       N10[N1-7] = N0
  269.       GOTO DD_Keypress            ; Start w/new key
  270.       ENDIF
  271.    IF STRCMP S0 "08"                    ; If enter with backspace
  272.       N10[N1-7] = N0
  273.       GOTO DD_Keypress            ; Start w/new key
  274.       ENDIF
  275. ;
  276. ;    The space bar terminates data entry
  277. ;
  278. DD_Test:
  279.    IF STRCMP S0 " "                     ; If space key
  280.       S0 = "4D00"                       ; Fake a cursor right
  281.       GOTO DD_Store            ; End of routine
  282.       ENDIF
  283. ;
  284. ;    Look for special chars (tab, and backspace, and non-ASCII)
  285. ;
  286.    SWITCH S0
  287.       CASE "09"                         ; Tab key
  288.      GOTO DD_Store
  289.       ENDCASE
  290.       CASE "0D"                         ; Carriage rtn end field here
  291.      S0 = "4D00"                    ; Fake a cursor right
  292.      GOTO DD_Store
  293.       ENDCASE
  294.       CASE "08"                         ; Backspace
  295.      IF GT N6 0            ; If anything entered
  296.         CURSOR N1,N2
  297.         N2 = N2-1
  298.         LOCATE N1,N2
  299.         ATSAY  N1,N2 (default) " "
  300.         S1(N6:N6) = " "
  301.         N6 = N6-1
  302.         ENDIF
  303.      GOTO DD_Keypress        ; And go for another key
  304.       ENDCASE
  305.    ENDSWITCH
  306.    IF NOT NULL S0(1:3)            ; Not ascii key
  307.       GOTO DD_Store            ; End of routine
  308.       ENDIF
  309. ;
  310. ;    Filter only numeric chars here
  311. ;
  312.    CTOI S0 N0                ; Easier comparison
  313.    IF LT N0 48                ; 48 = '0'
  314.       GOTO DD_Invalid
  315.       ENDIF
  316.    IF GT N0 57                ; 56 = '9'
  317.       GOTO DD_Invalid
  318.       ENDIF
  319. ;
  320. ;    Add the character to our field being constructed
  321. ;
  322.    S9(N6:N6) = S0            ; Add the char
  323.    N6 = N6+1
  324. ;
  325. ;    Display the keystroke in S0
  326. ;
  327.    CURSOR N1,N2
  328.    ATSAY N1,N2 (default) S0(0:0)
  329.    N2 = N2+1                ; Increment cursor
  330.    LOCATE N1,N2
  331. ;
  332. ;    Loop for more (unless field is full)
  333. ;
  334.    IF GE N6 3                ; 3 digits entered
  335.       S0 = "4D00"                       ; Fake a cursor right
  336.       GOTO DD_Store            ; Can't be more
  337.       ENDIF
  338.    GOTO DD_Keypress
  339. ;
  340. ;    Invalid keypress
  341. ;
  342. DD_Invalid:
  343.    SOUND 100,100
  344. ;
  345. ;    Request the next key
  346. ;
  347. DD_Keypress:
  348.    KEYGET S0
  349.    GOTO DD_Test
  350. ;
  351. ;    Update the remainder of the display too
  352. ;
  353. DD_Store:
  354.    IF EQ N6 0                ; Nothing stored
  355.       GOTO DD_Exit            ; Cancel entry
  356.       ENDIF
  357.    N3 = S9                ; Save current value
  358.    IF GT N3 100             ; Set upper bound
  359.       N3 = 100
  360.       ENDIF
  361.    IF LT N3 1                ; Set lower bound
  362.       N3 = 1
  363.       ENDIF
  364.    N0 = N10[N1-7]
  365.    N0 = N3+(N0/1000)*1000        ; Add new DD# and old LD#
  366.    N10[N1-7] = N0
  367. ;
  368. ;    Update the display and we're done
  369. ;
  370. DD_Exit:
  371.    N0 = N10[N1-7]
  372.    GOSUB One_Field            ; Using N0,N1
  373.    RETURN
  374. ;
  375. ; ----- Subroutine: Enter a long distance #
  376. ;    .. on entry S0 -> The first keystroke
  377. ;
  378. Enter_LD:
  379.    SWITCH S0
  380.      CASE "+"
  381.     N0 = 1
  382.      ENDCASE
  383.      CASE "-"
  384.     N0 = 2
  385.      ENDCASE
  386.      CASE "#"
  387.     N0 = 3
  388.      ENDCASE
  389.      CASE "@"
  390.     N0 = 4
  391.      ENDCASE
  392.      CASE "1"
  393.     N0 = 1
  394.      ENDCASE
  395.      CASE "2"
  396.     N0 = 2
  397.      ENDCASE
  398.      CASE "3"
  399.     N0 = 3
  400.      ENDCASE
  401.      CASE "4"
  402.     N0 = 4
  403.      ENDCASE
  404.      DEFAULT
  405.     N0 = 0
  406.     S0 = " "
  407.     SOUND 100,100
  408.      ENDCASE
  409.    ENDSWITCH
  410. ;
  411. ;    Clear the field, and redisplay
  412. ;
  413.    CURSOR N1,N2
  414.    ATSAY  N1,N2 (Default) S0(0:0)
  415. ;
  416. ;    Update the remainder of the display too
  417. ;
  418.    N3 = N0                ; Save current value
  419.    N0 = N10[N1-7]
  420.    N0 = N0-(N0/1000)*1000        ; Extract DD#
  421.    N0 = N0+N3*1000            ; Add new DD#
  422.    N10[N1-7] = N0
  423. ;
  424. ;    Flesh out the display and we're done
  425. ;
  426.    GOSUB One_Field            ; Using N0,N1
  427.    RETURN
  428. ;
  429. ; ----- Display a single field
  430. ;    .. N0 -> The LD code*1000 + the dialing directory #
  431. ;       N1 -> The display line #
  432. ;    .. N2,N3,S10,S11 are modified
  433. ;
  434. One_Field:
  435.    S10 = "                                                                      "
  436.    ATSAY N1,7  (Default) S10(0:67)
  437. ;
  438. ;    Extract the LD code and dialing directory #
  439. ;
  440.    N2 = N0/1000             ; Set LD #
  441.    N3 = N0-(N0/1000)*1000        ; Set dialing directory #
  442. ;
  443. ;    Set-up the LD code for display
  444. ;
  445.    IF NOT ZERO N2
  446.       S10(0:2) = " "*N2
  447.       LD S11 N2
  448.       S10(8:30) = S11
  449.       ENDIF
  450. ;
  451. ;    Set-up the dialing directory # for display
  452. ;
  453.    IF NOT ZERO N3
  454.       S10(4:6) = N3
  455.       DNUM S11 N3
  456.       S10(32:45) = S11
  457.       DIRECTORY S11 N3
  458.       S10(47:79) = S11
  459.       ENDIF
  460. ;
  461. ;    And display the entry
  462. ;
  463.    ATSAY N1,7  (Default) S10(0:67)
  464.    RETURN
  465. ;
  466. ; ----- Subroutine: Display all fields
  467. ;    .. N0,N1,N2,N3,S10,S11 are destroyed
  468. ;
  469. All_Fields:
  470.    N0 = N10
  471.    N1 = 7
  472.    GOSUB One_Field            ; Display a single field
  473.  
  474.    N0 = N11
  475.    N1 = 8
  476.    GOSUB One_Field            ; Display a single field
  477.  
  478.    N0 = N12
  479.    N1 = 9
  480.    GOSUB One_Field            ; Display a single field
  481.  
  482.    N0 = N13
  483.    N1 = 10
  484.    GOSUB One_Field            ; Display a single field
  485.  
  486.    N0 = N14
  487.    N1 = 11
  488.    GOSUB One_Field            ; Display a single field
  489.  
  490.    N0 = N15
  491.    N1 = 12
  492.    GOSUB One_Field            ; Display a single field
  493.  
  494.    N0 = N16
  495.    N1 = 13
  496.    GOSUB One_Field            ; Display a single field
  497.  
  498.    N0 = N17
  499.    N1 = 14
  500.    GOSUB One_Field            ; Display a single field
  501.  
  502.    N0 = N18
  503.    N1 = 15
  504.    GOSUB One_Field            ; Display a single field
  505.  
  506.    N0 = N19
  507.    N1 = 16
  508.    GOSUB One_Field            ; Display a single field
  509.    RETURN                ; And we're done
  510. ;
  511. ; ----- Subroutine: Parse a parameter string in S19 into numeric variables
  512. ;    .. N10-N19 are returned either set to 0, or a dialing directory #
  513. ;       S19 -> The saved dialing command
  514. ;    .. N0,N1 are modifed
  515. ;
  516. Parse_Parm:
  517.    FOR N0 = 0,36,4            ; 10x
  518.      N1 = N0+3
  519.      ATOI S19(N0:N1) N1
  520.      IF ERROR                ; Delimiter
  521.     N1 = 0
  522.     ENDIF
  523.      N10 = N11
  524.      N11 = N12
  525.      N12 = N13
  526.      N13 = N14
  527.      N14 = N15
  528.      N15 = N16
  529.      N16 = N17
  530.      N17 = N18
  531.      N18 = N19
  532.      N19 = N1
  533.      ENDFOR
  534.    RETURN
  535. ;
  536. ; ----- Subroutine: Get the last dialing parameter used
  537. ;    .. S19 returns the parameter
  538. ;
  539. Get_Last:
  540.    S19 = "DIALER.DAT"
  541.    IF ISFILE S19
  542.       FOPENI "DIALER.Dat" TEXT           ; Name of data file
  543.       IF FAILURE
  544.      GOTO No_Get
  545.      ENDIF
  546.    ELSE
  547.       GOTO No_Get
  548.       ENDIF
  549. ;
  550. ;    Read the firt record in the file
  551. ;
  552.    READ S19 80 N0
  553.    IF EOF
  554.       GOTO No_Get
  555.       ENDIF
  556.    FCLOSEI                ; Done for now
  557.    RETURN
  558. ;
  559. ;    No file or record
  560. ;
  561. No_Get:
  562.    S19 = "   "
  563.    RETURN
  564. ;
  565. ; ----- Subroutine: Store current selections for next use
  566. ;    .. S19 is modified
  567. ;
  568. Set_Last:
  569.    S19 = "DIALER.DAT"
  570.    FOPENO "DIALER.Dat" TEXT           ; Name of data file
  571.    IF FAILURE
  572.       RETURN
  573.       ENDIF
  574.    S19(0:4)   = N10
  575.    S19(5:9)   = N11
  576.    S19(10:14) = N12
  577.    S19(15:19) = N13
  578.    S19(20:24) = N14
  579.    S19(25:29) = N15
  580.    S19(30:34) = N16
  581.    S19(35:39) = N17
  582.    S19(40:44) = N18
  583.    S19(45:49) = N19
  584.    WRITE S19 50
  585.    FCLOSEO
  586.    RETURN
  587. ;
  588. ; ----- Open a window with blank fields
  589. ;
  590. Window:
  591.    SAVE   1,5  23 75
  592.    BOX      1,5  23 75 (default)
  593.    ATSAY  1,7  (default)   " COM-AND Multi-dialer "
  594.  
  595.    ATSAY  2,7  (default)   "Select up to 10 dialing directory entries (using or not using a long"
  596.    ATSAY  3,7  (default)   "distance prefix).  Sequential redial begins when you hit return."
  597.    ATSAY  4,5  (default) "├─────────────────────────────────────────────────────────────────────┤"
  598.    ATSAY  5,7  (default)   "LD# DD#   (from LD directory)        (from dialing directory)"
  599.    ATSAY  6,7  (default)   "--- --- ----------------------- -------------- --------------------"
  600.  
  601.    ATSAY 17,5  (default) "├─────────────────────────────────────────────────────────────────────┤"
  602.    ATSAY 18,7  (default)   "Use cursor up/down to select a line in the display.  Use cursor left"
  603.    ATSAY 19,7  (default)   "and right to select a field.  PgUp/PgDn cycle possible values."
  604.    ATSAY 20,7  (default)   "LD codes are 0,' ' = none, 1 or +, 2 or -, 3 or #, 4 or @.  DD codes"
  605.    ATSAY 21,7  (default)   "are 1-100.  Current values are always displayed.  Empty entries are"
  606.    ATSAY 22,7  (default)   "ignored.  A carriage return begins the dialing sequence."
  607.    ATSAY 23,30 (default)            " Press ESC to exit "
  608.    RETURN
  609. ;
  610. ; ----- Subroutine: Set for dialing
  611. ;    .. N2 on entry is the directory #
  612. ;
  613. Set_Dialing:
  614.    DPARM S0 N2                ; Get dialing parms
  615.    ATSAY 21,7  (default) S0
  616.  
  617.    S1 = S0(5:5)
  618.    SWITCH S1                ; Parity
  619.       CASE "E"
  620.     SET PARITY EVEN
  621.       ENDCASE
  622.       CASE "O"
  623.     SET PARITY ODD
  624.       ENDCASE
  625.       CASE "N"
  626.     SET PARITY NONE
  627.       ENDCASE
  628.    ENDSWITCH
  629.  
  630.    S1 = S0(7:7)
  631.    SWITCH S1                ; Data bits
  632.       CASE "7"
  633.     SET DATA 7
  634.       ENDCASE
  635.       CASE "8"
  636.     SET DATA 8
  637.       ENDCASE
  638.    ENDSWITCH
  639.  
  640.    S1 = S0(9:9)
  641.    SWITCH S1                ; Stop bits
  642.       CASE "1"
  643.     SET STOP 1
  644.       ENDCASE
  645.       CASE "2"
  646.     SET STOP 2
  647.       ENDCASE
  648.    ENDSWITCH
  649.  
  650.    S1 = S0(0:3)
  651.    SWITCH S1                ; Baud rate
  652.       CASE " 300"
  653.     SET BAUD 300
  654.       ENDCASE
  655.       CASE "1200"
  656.     SET BAUD 1200
  657.       ENDCASE
  658.       CASE "2400"
  659.     SET BAUD 2400
  660.       ENDCASE
  661.       CASE "4800"
  662.     SET BAUD 4800
  663.       ENDCASE
  664.       CASE "9600"
  665.     SET BAUD 9600
  666.       ENDCASE
  667.    ENDSWITCH
  668.  
  669.    IF STRCMP S0(11:11) "Y"              ; Echo Y/N
  670.       SET DUPLEX HALF
  671.    ELSE
  672.       SET DUPLEX FULL
  673.    ENDIF
  674.    RETURN
  675. ;
  676. ;    This exit is taken after we begin to perform the dialing sequence
  677. ;
  678. Exit_Perform:
  679.    HANGUP                ; HANGUP - may be dialing
  680.    RESTORE                ; Clear 2nd window
  681.    GOTO Exit
  682. ;
  683. ; ----- We got a connection
  684. ;    .. N1 -> The selected entry
  685. ;
  686. Got_It:
  687.    RESTORE                ; Clear 2nd window
  688.    RESTORE                ; Clear 1st window
  689.    LOCATE N8,N9             ; Restore cursor
  690.    SET RDISP ON             ; Turn on display
  691. ;
  692. ;    Clear the entry selected here from the saved list
  693. ;
  694.    N0 = 0                ; Set cleared value
  695.    N10[N1-7] = N0
  696.    GOSUB Set_Last            ; Save updated list for next time
  697. ;
  698. ;    Log connection
  699. ;
  700.    DIREC S0 N2                ; Get the name
  701.    SET CLOCK NEW            ; Turn on screen clock
  702.    CLOG "CONNECT (dialer.cmd): "*S0
  703. ;
  704. ;    If this entry has a script, execute it
  705. ;
  706.    DSCRIPT S0,N2            ; Look for a script
  707.    IF NOT NULL S0
  708.       SET LINKED ON            ; Fake from Alt-D
  709.       EXECUTE S0            ; Chain to new script
  710.       ENDIF
  711.    ALARM                ; SOund an alarm (if enabled)
  712.    CONNECT                ; Go to terminal mode
  713. ;
  714. ; ----- We are to perform the redial - is there anything?
  715. ;
  716. Perform:
  717.    N6 = 0
  718.    FOR N1 = 7,16
  719.        N0 = N10[N1-7]
  720.        N2 =  N0-N0/1000*1000        ; DD#
  721.        IF NOT ZERO N2            ; If there's an entry here
  722.       GOTO Set_Up            ; Start
  723.       ENDIF
  724.        ENDFOR
  725. ;
  726. ;    Nothing to do
  727. ;
  728.    SOUND 100,100
  729.    GOTO Main_Loop            ; And continue
  730. ;
  731. ;    Set-up a new environment
  732. ;
  733. Set_Up:
  734. ;* TRACE ON
  735.    SET TTHRU ON             ; Allow typethrough
  736.    KFLUSH
  737.    SET RDISP OFF            ; Turn off display
  738.    ON ESCAPE GOSUB Exit_Perform     ; New exit
  739.    LEGEND " Cycling through selected #'s"
  740. ;
  741. ;    Save the current selection for the next invocation
  742. ;
  743.    GOSUB Set_Last            ; Save whole list in case of Escape
  744. ;
  745. ;    Open a window over the last one.
  746. ;
  747.    SAVE   17,5 23 75
  748.    BOX      17,5 23 75 (default)
  749.    ATSAY  17,7    (default) " COM-AND Dialing "
  750.    ATSAY  23,22 (default) " CR to move to next, ESC to terminate "
  751. ;
  752. ;    Set control values
  753. ;
  754.    N6 = 0                ; Display counter
  755.    N5 = 35                ; TImeout in seconds
  756. ;
  757. ;    Loop until escape or connect
  758. ;    .. Note: N1 and N2 must be preserved within the loop
  759. ;
  760. Loop:
  761.    FOR N1 = 7,16            ; Loop index (preserve this value!)
  762.        ;
  763.        ;  Get the current entry's value (0 = not used)
  764.        ;
  765.        N0 = N10[N1-7]
  766.        N2 =  N0-N0/1000*1000        ; DD# (preserve this value!)
  767.        N3 =  N0/1000*1000        ; LD#
  768.  
  769.        IF NOT ZERO N2
  770.       N6 = N6+1
  771.       ATSAY 18,7  (default) "Retry #: "*N6*";  Started: "*"_time"*";  Timeout = "*N5*" seconds"
  772.       ATSAY 19,7  (default) "                              " ; clear
  773.       ATSAY 20,7  (default) "                              " ; clear
  774.       ATSAY 21,7  (default) "                              " ; clear
  775.       ATSAY 22,7  (default) "                              " ; clear
  776.       ;
  777.       ;  Using values for this entry get name, number and LD prefix
  778.       ;
  779.       DIRECTORY S1 N2
  780.       DNUM S2 N2
  781.       LD S3 N3
  782.       ATSAY 19,7  (default) S1
  783.       ATSAY 20,7  (default) S2&S3
  784.       ;
  785.       ;  Set parity, data and stop bits, echo, and speed
  786.       ;
  787.       GOSUB Set_Dialing
  788.       ;
  789.       ;  Hangup and send the dialing sequence
  790.       ;
  791.       RFLUSH
  792.       S0 = "_DPREFIX" & S3 & S2 & "_DSUFFIX"&""
  793.       ATSAY 22,7  (default) "Hanging up  "
  794.       HANGUP
  795.       WAITFOR "OK" 5                ; Clear line of modem's "OK"
  796.       TRANS S0
  797.       ATSAY 22,7  (default) "Dialing     "
  798.       ;
  799.       ;  Wait for a non-null response from the modem
  800.       ;
  801.       N0 = N5
  802.       SET TIMER
  803.       WHILE GT N0 0
  804.          RGET S0 80 N0        ; Wait up to a limit secs
  805.          IF NOT NULL S0
  806.         IF FIND S0 "_MCONNECT"&""  ; Trim trailing blanks
  807.            GOTO Got_It
  808.         ELSE
  809.            ATSAY 22,7  (default) "              "
  810.            ATSAY 22,7  (default) S0
  811.            PAUSE 5
  812.            N0 = -N5        ; Force end of loop
  813.            ENDIF
  814.         ENDIF
  815.          TSINCE N3,N3,N4        ; Throw away Hrs
  816.          N0 = N0-N4         ; Compute total time
  817.          ENDWHILE
  818.       ENDIF
  819.        ENDFOR
  820.    GOTO Loop                ; Loops forever - 'til ESC or connect
  821.